package com.shop.operator.service.impl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shop.mapper.ItemCatMapper;
import com.shop.model.ItemCat;
import com.shop.model.ItemCatExample;
import com.shop.model.ItemCatExample.Criteria;
import com.shop.operator.service.ItemCatService;

@Service("itemCatServiceBean")
public class ItemCatServiceBean implements ItemCatService {

	@Autowired /*@Qualifier*/
	ItemCatMapper itemCatMapper;
	@Override
	public List<ItemCat> findByParentId(Long parentId) throws Exception{
		ItemCatExample catExample = new ItemCatExample();
		Criteria criteria = catExample.createCriteria();
		criteria.andParentIdEqualTo(parentId);
		List<ItemCat> list = itemCatMapper.selectByExample(catExample);
		
		return list;
	}
	@Override
	public void add(ItemCat itemCat) throws Exception{
		itemCatMapper.insert(itemCat);
	}
	@Override
	public void delete(List<Long> ids) throws Exception {
		ItemCatExample example = new ItemCatExample();
		example.createCriteria().andIdIn(ids);
		itemCatMapper.deleteByExample(example);
		
	}
	@Override
	public void update(ItemCat itemCat) throws Exception {
		itemCatMapper.updateByPrimaryKey(itemCat);
		
	}

}
